package com.youku.component.connection;

import java.util.HashMap;
import java.util.Map;

public class ConnectorFactory {

	private static final Map<String, Connector> connectors;

	static {
		connectors = new HashMap<>();

		connectors.put("mysql", new MysqlConnector());

		connectors.put("redis", new RedisConnector());
	}

	public static Connector build(Map<String, String> map) {
		String type = map.get("db");
		Connector connector = connectors.get(type);

		if (connector == null)
			throw new RuntimeException("目前不支持" + type + "数据库");

		return connector.build(map);
	}
}
